<!DOCTYPE html>
<html lang="en">
<head>
    <title>报告详情</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-store, must-revalidate">
    <meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT">
    <meta http-equiv="expires" content="-1">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" href="/dist/img/icon.png" type="image/x-icon">
    <!-- Bootstrap 3.3.6 -->
    <link rel="stylesheet" href="/dist/plugins/bootstrap/css/bootstrap.min.css">
    <!--字体-->
    <link rel="stylesheet" href="/dist/css/font-awesome.min.css">
    <!--图标-->
    <link rel="stylesheet" href="/dist/css/ionicons.min.css">
    <!--OA主样式-->
    <link href="/dist/plugins/ztree/css/zTreeStyle/zTreeStyle.css" rel="stylesheet"/>
    <link rel="stylesheet" href="/dist/plugins/select2/select2.min.css">
    <link rel="stylesheet" href="/dist/css/OA.min.css?t=e9c5bb62">
    <link rel="stylesheet" href="/dist/css/skins/OA-skins.min.css?t=66b457d6">
    <style>
        .selectOption {
            margin-right: 20px;
        }

        .selectOption span {
            color: rgb(34, 139, 238);
            font-weight: bold;
            cursor: pointer;
        }

        .careful {
            color: red;
        }

        .ztree {
            position: absolute;
            background: #fff;
            border: 1px solid #d2d6de;
            border-top: none;
            width: 200px;
            overflow: hidden;
            display: none;
            z-index: 2;
        }

        .selectOrg {
            width: 200px;
            border: 1px solid #d2d6de;
            border-radius: 0;
            padding: 6px 12px;
            height: 25px !important;
            position: relative;
        }

        .select2-selection__arrow {
            height: 20px;
            position: absolute;
            top: 1px;
            right: 3px;
            width: 20px;
            cursor: pointer;
        }

        .select2-selection__arrow b {
            border-color: #888 transparent transparent transparent;
            border-style: solid;
            border-width: 5px 4px 0 4px;
            height: 0;
            left: 50%;
            margin-left: -4px;
            margin-top: 0px;
            position: absolute;
            top: 50%;
            width: 0;
        }

        .biTian {
            float: left;
            left: 1px;
            top: 3px;
            color: red;
        }

        .jiaobiao3 {
            position: relative;
        }

        .jiaobiao3 i {
            display: block;
            width: 6px;
            height: 6px;
            background: url("/dist/img/newLog3.png");
            position: absolute;
            top: 0px;
            right: 0px;
        }
        .content {
            padding: 8px 8px 0 8px;
        }
    </style>
</head>
<body>
<section class="content" id="app">
    <div class="box-header" style="text-align: right; padding-bottom: 10px;">
        <div class="pull-left selectOption" @click="changeJobStates('0,-1,-2','在职人员')">
            在职：<span>{{jobStates.activeJob}}</span>人
        </div>
        <div class="pull-left selectOption" @click="changeJobStates('-2','试岗人员')"> 试岗：<span>{{jobStates.tryJob}}</span>人
        </div>
        <div class="pull-left selectOption" @click="changeJobStates('-1','试用期人员')">
            试用期：<span>{{jobStates.trialJob}}</span>人
        </div>
        <div class="pull-left selectOption" @click="changeJobStates('1','离职人员')"> 离职：<span>{{jobStates.leaveJob}}</span>人
        </div>
        <div class="pull-left selectOption" @click="changeJobStates('0,-1,-2,1','合计')">
            合计：<span>{{jobStates.leaveJob+jobStates.trialJob+jobStates.tryJob+jobStates.activeJob}}</span>人
        </div>
        <!--<div class="pull-left selectOption careful"  @click="changeArchivaType"> 提示：<span>{{jobStates.archivesJob}}</span>人档案不全</div>-->
        <div class="pull-left selectOption careful" @click="changeArchivaType('0,-1,-2','在职人员')"> 提示：<span>{{jobStates.archivesJob}}</span>人档案不全
        </div>
    </div>
    <div class="box-header" style="padding-bottom: 10px;">
        <div class="pull-left" style="width:200px;">
            <div class="selectOrg">
                <div class="value">{{orgName}}</div>
                <span class="select2-selection__arrow" role="presentation"><b role="presentation"></b></span>
            </div>
            <ul class="ztree" id="ulGroupCompanyDepartRole"></ul>
        </div>
        <input class="pull-left form-control pull-left input-sm" type="text" v-model="searchParams.beginTime"
               @focus="showDatePicker($event)" placeholder="请选择开始时间" style="width: 150px;">
        <input class="pull-left form-control pull-left input-sm" type="text" v-model="searchParams.endTime"
               @focus="endDatePicker($event)" placeholder="请选择结束时间" style="width: 150px;">
        <input type="text" placeholder="姓名" class="form-control pull-left input-sm"
               style="width: 150px; margin-left: 10px;" v-model="searchParams.key" @keyup.enter="getList">
        <button type="button" class="btn oaBtn btn-sm pull-left" style="margin-left: 10px;" @click="getList">查询</button>
        <button type="button" class="btn oaBtn pull-right btn-sm" id="quitBtn" v-if="isShowBtn('personnelLeave')"
                @click="quitBtn('editType')">办理离职
        </button>
        <button type="button" class="btn oaBtn pull-right btn-sm" style="margin-right: 20px;" id="changePostBtn"
                v-if="isShowBtn('personnelChangePost')" @click="changePostBtn">调岗
        </button>
        <button type="button" class="btn oaBtn pull-right btn-sm" style="margin-right: 20px;" id="entryBtn"
                v-if="isShowBtn('personnelAdd')" @click="entryBtn('editType')">办理入职
        </button>
        <button type="button" class="btn oaBtn pull-right btn-sm" style="margin-right: 20px;" id="announcementBtn"
                v-if="isShowBtn('personnelAnnouncement')" @click="announcementBtn">发布通告
        </button>
    </div>
    <table class="table table-hover text-center">
        <thead>
        <tr>
            <th style="width:20px;" class="tableTitle">

            </th>
            <th style="width: 50px;" class="tableTitle">序号</th>
            <th class="tableTitle">姓名</th>
            <th class="tableTitle">性别</th>
            <th class="tableTitle">联系方式</th>
            <th class="tableTitle">所属公司</th>
            <th class="tableTitle">部门</th>
            <th class="tableTitle">岗位</th>
            <th class="tableTitle">上级</th>
            <th class="tableTitle">在职状态</th>
            <th class="tableTitle">入职日期</th>
            <th class="tableTitle">离职日期</th>
            <th class="tableTitle">入职天数</th>
            <th  class="tableTitle"style="width: 120px;">操作</th>
        </tr>
        </thead>
        <tbody>

        <tr v-for="(item,i) in list">
            <td><input type="checkbox" @click="checkedOne(item)" :checked="selectId==item.id"/></td>
            <td>{{i+1}}</td>
            <!--<td ><i class="biTian" v-if="item.archivaType==0">*</i>{{item.name}}</td>-->
            <td :class="item.archivaType===0?'jiaobiao3':''"><i></i>{{item.name}}</td>
            <td>{{item.sex=="0"?"男":"女"}}</td>
            <td>{{item.tel}}</td>
            <td>{{item.companyName}}</td>
            <td>{{item.departName}}</td>
            <td>{{item.roleName}}</td>
            <td>{{item.parentName?item.parentName:"-"}}</td>
            <td>{{Flage2Name(item.jobState)}}</td>
            <td>{{item.entryDate}}</td>
            <td>{{item.leaveDate}}</td>
            <td>{{item.dayNumber?item.dayNumber+'天':"-"}}</td>
            <td>
                <a href="javascript:void(0);" @click="gotoDetail(item,'look')">查看</a>
                <a href="javascript:void(0);" @click="gotoDetail(item,'edit','editType')" v-if="isShowBtn('personnelAdd')">修改</a>
                <a href="javascript:void(0);" @click="gotoDetail(item,'forget')" v-if="isShowBtn('personnelResetPwd')">重置密码</a>
                <a href="javascript:void(0);" @click="reEntry(item)" v-if="isShowBtn('personnelAdd')">重新入职</a>
            </td>
        </tr>
        </thead></table>
    <!-- /.box-body -->
    <div class="oa-pager text-center" style="margin-top: 5px;">
        共
        <span id="allCount"> 0 </span>条记录&nbsp;&nbsp;&nbsp;
        <span id="nowPage"> 1 </span>/<span id="allPage">1</span>&nbsp;&nbsp;&nbsp;
        <span class="oa-pager-button" id="first">首页</span>
        <span class="oa-pager-button" id="prev">上一页</span>
        <span class="oa-pager-button" id="next">下一页</span>
        <span class="oa-pager-button" id="last">尾页</span>
    </div>
    <!--<div class="oa-pager text-center" style="margin-top: 5px;">-->
    <!--共-->
    <!--<span id="allCount">{{pager.recordCount}}</span>条记录&nbsp;&nbsp;&nbsp;-->
    <!--<span id="nowPage">{{pager.requestPage}}</span>/<span id="allPage">{{pager.pageCount}}</span>&nbsp;&nbsp;&nbsp;-->
    <!--<span id="first" class="oa-pager-button">首页</span> <span id="prev" class="oa-pager-button">上一页</span> <span id="next" class="oa-pager-button">下一页</span> <span id="last" class="oa-pager-button">尾页</span></div>-->
</section>
<!--JQ-->
<script src="https://file.ggxqce.com/web/jquery-2.2.3.min.js"></script>
<!--插件JS-->
<script src="https://file.ggxqce.com/web/bootstrap.min.js"></script>
<!--框架已定义 JS-->
<script src="/dist/js/app_iframe.js?t=0b5caf39"></script>
<!--oa自定义  JS-->
<script src="/dist/js/oa.js?t=0c4d95a9"></script>
<script src="/dist/plugins/select2/select2.full.min.js"></script>
<!--日期控件-->
<script type="text/javascript" src="/dist/plugins/My97DatePicker/WdatePicker.js"></script>
<!--ztree组件所需js-->
<script type="text/javascript" src="/dist/plugins/ztree/js/jquery.ztree.all-3.5.min.js"></script>
<script type="text/javascript" src="/dist/plugins/ztree/js/jquery.ztree.exhide-3.5.js"></script>
<script type="text/javascript" src="/dist/plugins/easyui/plugins/jquery.menu.js"></script>
<script type="text/javascript" src="/dist/plugins/easyui/plugins/jquery.parser.js"></script>

<script src="https://file.ggxqce.com/web/vue.min.js"></script>
<script type="text/javascript" src="/dist/plugins/lhgdialog/lhgdialog.min.js?self=true"></script>
<script type="text/javascript">
    var zTreeCallback = {
        showIcon: function (treeeId, treeNode) {
            return treeNode.isParent;
        },
        onClick: function (event, treeId, treeNode) {
            if (treeNode.type == "root" && !getCurrentUser().superUser) {
                return;
            }
            app.orgName = treeNode.name;

            $.wyui.page.queryParams.companyId = "";
            $.wyui.page.queryParams.departId = "";
            $.wyui.page.queryParams.roleId = "";
            console.log(treeNode.type)
            switch (treeNode.type) {
                case 'company':
                    $.wyui.page.queryParams.companyId = treeNode.dataId;
                    break;
                case 'depart':
                    $.wyui.page.queryParams.departId = treeNode.dataId;
                    break;
                case 'role':
                    $.wyui.page.queryParams.roleId = treeNode.dataId;
                    break;
                default :
                    break;
            }
            this.selectId = '';
            $.wyui.page.getByPage();
            $(".ztree").hide();
        }
    };
    var zTreeSetting = {
        view: {
            showIcon: zTreeCallback.showIcon
        },
        data: {
            simpleData: {
                enable: true
            },
            keep: {
                parent: true
            }
        },
        callback: {
            onClick: zTreeCallback.onClick
        }
    };

</script>
<script type="text/javascript">
    $.wyui.page.dataUrl = server.ip + urlConfig.system.user.getUserViewByCondition;
    $.wyui.page.queryParams.companyId = getCurrentUser().superUser ? "" : getCurrentUser().companyId;
    $.wyui.page.queryParams.jobState = '';
    $.wyui.page.queryParams.archivaType = "";
    $.wyui.page.queryParams.entryDate = '';
    $.wyui.page.queryParams.key = '';
    $.wyui.page.getByPage_callback = function () {
    };
    $.wyui.page.getByPage_callback_new = function (r) {
        app.list = r.records;
        app.jobStates = r.jobStates;
    };

    var app = new Vue({
        el: '#app',
        data: {
            orgName: "组织机构",
            typeTitle: "在职人员",
            searchParams: {
                companyId: getCurrentUser().companyId,
                jobState: '',
                archivaType: '',
                key: '',
                beginTime: '',
                endTime: ''
            },
            pager: {},
            currentUser: getCurrentUser(),
            list: [],
            jobStates: {},
            selectId: '',
            rightOp: []
        },
        methods: {
            isHasRightOp: function (eName) {
                return $.inArray(eName, this.rightOp) > -1;
            },
            isShowBtn: function (eName) {
                if (this.isHasRightOp(eName)) {
                    return true;
                } else {
                    return false;
                }
            },
            checkedOne: function (item) {
                if (this.selectId == item.id) {
                    // 如果已经包含了该id, 则去除(单选按钮由选中变为非选中状态)
                    this.selectId = ""
                } else {
                    // 选中该checkbox
                    this.selectId = item.id
                }

                console.log(item);
            },
            Flage2Name: function (flage) {
                if (flage == "-2") return "试岗";
                if (flage == "-1") return "试用期";
                if (flage == "0") return "转正";
                if (flage == "1") return "离职";
                if (flage == "2") return "档案不全";
            },
            changeJobStates: function (jobState, type) {
                this.selectId = '';
                $.wyui.page.queryParams.archivaType = "";
                //$.wyui.page.queryParams.companyId = getCurrentUser().superUser?"":getCurrentUser().companyId;
                $.wyui.page.queryParams.jobState = jobState;
                $.wyui.page.queryParams.requestPage = 1;
                $.wyui.page.getByPage();
                this.orgName = app.orgName;
                //this.orgName="组织结构";
                console.log(type);
                this.typeTitle = type;
            },
            changeArchivaType: function (jobState, type) {
                //$.wyui.page.queryParams.companyId = getCurrentUser().superUser?"":getCurrentUser().companyId;
                this.selectId = '';
                /*$.wyui.page.queryParams.jobState = "";*/
                $.wyui.page.queryParams.jobState = jobState;
                $.wyui.page.queryParams.archivaType = 0;
                $.wyui.page.queryParams.requestPage = 1;
                $.wyui.page.getByPage();
            },

            showDatePicker: function (e) {
                var that = this;
                WdatePicker({
                    onpicked: function (dp) {
                        that.searchParams.beginTime = dp.cal.getNewDateStr();
                        return true;
                    },
                    onclearing: function (dp) {
                        that.searchParams.beginTime = ""
                        return true;
                    }
                });
                $(e.target).blur();
            },
            endDatePicker: function (e) {
                var that = this;
                WdatePicker({
                    onpicked: function (dp) {
                        that.searchParams.endTime = dp.cal.getNewDateStr();
                        return true;
                    },
                    onclearing: function (dp) {
                        that.searchParams.endTime = ""
                        return true;
                    }
                });
                $(e.target).blur();
            },

            getList: function () {
                this.selectId = '';
                $.wyui.page.queryParams.key = $.trim(this.searchParams.key);
                $.wyui.page.queryParams.beginTime = this.searchParams.beginTime;
                $.wyui.page.queryParams.endTime = this.searchParams.endTime;
                $.wyui.page.queryParams.jobState = '';
                $.wyui.page.queryParams.requestPage = 1;
                $.wyui.page.queryParams.pageSize = 30;
                $.wyui.page.getByPage();
            },
            reEntry: function (user) {
                var that = this;
                if (user.jobState == 1) {
                    $.wyui.postMethod('/user/reEntry.json',
                        {
                            userId: user.id,
                            jobState: -1
                        },
                        function (r) {
                            console.log(r);
                            if (r.result == true) {
                                alert("入职成功");
                                that.gotoDetail(user, 'edit');
                            } else {
                                alert("入职失败");
                            }
                        });
                }
            },
            gotoDetail: function (item, type, editType) {
                if (type == "forget") {
                    var r = confirm("您确定要重置 " + item.name + " 的账号密码吗？");
                    if (r == true) {
                        var data = {
                            pwd: "111111",
                            id: item.id,
                            updateUserId: getCurrentUser().id
                        };
                        $.wyui.postMethod(urlConfig.system.user.saveUser, data, function (r) {
                            alert("密码已重置成功")
                        });
                    }
                } else {
                    if (type == "look") {
                        top.$.dialog({
                            content: 'url:/page/personnel/entry.html?id=' + item.id + '&pageType=look',
                            title: item.name + "详情",
                            width: 904,
                            height: 613,
                            max: true,
                            min: true,
                            lock: true
                        }).max();
                    } else {
                        top.$.dialog({
                            content: 'url:/page/personnel/entry.html?id=' + item.id + '&pageType=' + type +'&editType=' + editType + "&t=" + new Date(),
                            title: '修改资料',
                            width: 904,
                            height: 613,
                            max: true,
                            min: true,
                            lock: true
                        }).max();
                    }

                }

            },
            entryBtn: function (editType) {
                var that = this;
                top.$.dialog({
                    content: 'url:/page/personnel/entry.html?pageType=edit' +'&editType=' + editType + "&t=" + new Date(),
                    title: '办理入职',
                    width: 904,
                    height: 613,
                    max: true,
                    min: true,
                    lock: true
                }).max();
            },
            announcementBtn: function () {
                var that = this;
                if (that.selectId == "") {
                    alert("请先勾选人员")
                } else {
                    top.$.dialog({
                        content: 'url:/page/personnel/announcement.html?id=' + that.selectId + '&t=' + new Date(),
                        title: '发布通告',
                        width: 660,
                        height: 455,
                        max: false,
                        min: false,
                        lock: true
                    });
                }
            },
            quitBtn: function (editType) {
                var that = this;
                if (that.selectId == "") {
                    alert("请先勾选人员")
                } else {
                    top.$.dialog({
                        content: 'url:/page/personnel/quit.html?id=' + that.selectId +'&editType=' + editType +'&t=' + new Date(),
                        title: '办理离职',
                        width: 662,
                        height: 300,
                        max: false,
                        min: false,
                        lock: true
                    });
                }
            },
            changePostBtn: function () {
                var that = this;
                if (that.selectId == "") {
                    alert("请先勾选人员")
                } else {
                    top.$.dialog({
                        content: 'url:/page/personnel/changePost.html?id=' + that.selectId + '&t=' + new Date(),
                        title: '调岗',
                        width: 662,
                        height: 280,
                        max: false,
                        min: false,
                        lock: true
                    });
                }
            }
        },
        mounted: function () {
            var that = this;
            //查询用户有哪些权限
            $.wyui.postMethod(urlConfig.system.rightOp.getRightOpByUserId, {userId: getCurrentUser().id}, function (rightOp) {
                // alert(JSON.stringify(rightOp))
                for (var i = 0; i < rightOp.length; i++) {
                    that.rightOp.push(rightOp[i].eName);
                }

                console.log("权限列表如下：");
                console.log(that.rightOp);

            });
            $.wyui.page.queryParams.archivaType = "";
            $(".select2").select2();

            $.wyui.postMethod(urlConfig.system.system.getOrgTreeNodesByUserId, {userId: getCurrentUser().id}, function (nodes) {
                that.treeObj = $.fn.zTree.init($("#ulGroupCompanyDepartRole"), zTreeSetting, nodes);
            });

            $.wyui.page.getByPage();

            $(".selectOrg").click(function () {
                $(".ztree").toggle();
            });
            $(document).bind('click', function () {
                $(".ztree").hide();
            });

            $('.ztree,.selectOrg').bind('click', function (e) {
                e.stopPropagation();
            });

        }
    });
</script>

</body>
</html>